package br.com.gc.rfqx.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.gc.rfqx.model.dao.CustomerDao;
import br.com.gc.rfqx.model.entity.Customer;


@Service
public class CustomerService {

	
	@Autowired
	private CustomerDao dao;

	@Transactional	
	public void save ( Customer customer  ) {
		
		if (customer.getId() == null) {
			dao.create(customer);
		} else {
			dao.update(customer);
		}
		
	}
	
	public List<Customer> list() {
		return dao.listAll();
	}
	
	public CustomerDao getDao() {
		return dao;
	}

	public void setDao(CustomerDao dao) {
		this.dao = dao;
	}
	
	
	
	
}
